// 开发依赖
/* eslint-disable */
const path = require('path');
const webpack = require('webpack');
const { merge } = require('webpack-merge');
// 优化显示报错信息的插件
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');

const common = require('./webpack.common');

module.exports = merge(common, {
  mode: 'development', // 开发模式
  devtool: 'eval-cheap-module-source-map', // 开发模式使用的sourceMap
  // 开发服务器配置
  devServer: {
    port: 9090,
    hot: true, // 开启HMR
    open: true,
    contentBase: path.join(__dirname, './public'),
    proxy: {
      '/api/': {
        target: 'http://xxxxx',
        pathRewrite: {
          '^/api': '',
        },
        changeOrigin: true,
      },
    },
  },
  plugins: [
    // HMR插件
    new webpack.HotModuleReplacementPlugin(),
    new FriendlyErrorsWebpackPlugin(),
  ],
});
